#include <stdio.h>
#include <stdlib.h>
#include "global.h"
#include "RegisterFile.h"

 RegFilePtr  newRegFile(void) {
	RegFilePtr regFile = (RegFilePtr) malloc(sizeof(RegFileStr));
	regFile->setRegFile = setRegFile;
	regFile->getRegFile = getRegFile;
	int i;
	for(i = 0; i < NO_OF_REGISTER; i++){
          regFile->regSet[i] = newRegister();
          }
	return regFile;
}


unsigned short getRegFile(RegFilePtr this, int regNo) {
   RegisterPtr current = (RegisterPtr) this->regSet[regNo];
	if (current == NULL ) {
		return NULL_POINTER_ERROR;
	} else {
		current =(RegisterPtr) this->regSet[regNo];
	}
	return current;
 }

int setRegFile(RegFilePtr this, int regNo,unsigned short newValue){
	 this->regSet[regNo] =  newValue;
 }


int main() {
  RegFilePtr regfile = newRegFile();
  regfile->setRegFile(regfile, 5, 0xa0ff);
  printf("%x",regfile->getRegFile(regfile, 5));


  getchar();
	return 0;

}
